package org.abc.fund.controller.funds;

import org.abc.fund.entity.funds.FundHolding;
import org.abc.fund.service.funds.FundHoldingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/fund-holding")
public class FundHoldingController {

    @Autowired
    private FundHoldingService fundHoldingService;

    @GetMapping("/{fundCode}")
    public List<FundHolding> getHoldings(@PathVariable String fundCode) {
        return fundHoldingService.getHoldingsByFundCode(fundCode);
    }

    @PostMapping("/add")
    public FundHolding addHolding(@RequestBody FundHolding holding) {
        return fundHoldingService.addHolding(holding);
    }

    @DeleteMapping("/delete/{id}")
    public void deleteHolding(@PathVariable Long id) {
        fundHoldingService.deleteHolding(id);
    }
}
